// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue';
import message1 from './message1';
import message2 from './message2';
import message3 from './message3';
import message4 from './message4';

const VueTest1 = Vue.extend(message1);
const VueTest2 = Vue.extend(message2);
const VueTest3 = Vue.extend(message3);
const VueTest4 = Vue.extend(message4);

function CreateText1(opt) {
  const vm1 = new VueTest1({
    data() {
      return {
        messageIsShow: opt.messageIsShow || false,
        type: opt.type || 'info',
        msg: opt.msg || '这是个弹出框',
        delay: opt.delay,
        closeIconIsShow: false,
        center: opt.center || false,
        bgcolor: opt.bgcolor || false,
        isHtml: opt.isHtml || false,
        title: opt.title || '标题',
        msg_2: opt.msg || '提示的内容',
      };
    },
  });
  vm1.$mount();
  document.body.appendChild(vm1.$el);
}
function CreateText2(opt) {
  const vm2 = new VueTest2({
    data() {
      return {
        messageIsShow: opt.messageIsShow || false,
        type: opt.type || 'info',
        msg: opt.msg || '这是个弹出框',
        delay: opt.delay || 0,
        title: opt.title || '标题',
        msg_2: opt.msg_2 || '文本',
        closeIconIsShow: false,
      };
    },
  });
  vm2.$mount();
  document.body.appendChild(vm2.$el);
}
function CreateText3(opt) {
  const vm3 = new VueTest3({
    data() {
      return {
        messageIsShow: opt.messageIsShow || false,
        msg: opt.msg || '这是个弹出框',
        delay: opt.delay,
        type: opt.type || 'top_right',
        rightRoLeft: opt.rightRoLeft || 'right',
        title: opt.title || '标题',
      };
    },
  });
  vm3.$mount();
  document.body.appendChild(vm3.$el);
}
function CreateText4(opt) {
  const vm4 = new VueTest4({
    data() {
      return {
        messageIsShow: opt.messageIsShow || false,
        msg: opt.msg || '这是个弹出框',
        delay: opt.delay || 4000,
        title: opt.title || '标题',
      };
    },
  });
  vm4.$mount();
  document.body.appendChild(vm4.$el);
}

export default {
  install(_) {
    /* eslint-disable no-param-reassign */
    _.prototype.$message1 = CreateText1;
    _.prototype.$message2 = CreateText2;
    _.prototype.$message3 = CreateText3;
    _.prototype.$message4 = CreateText4;
  },
};
